layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;
        //监听提交
        form.on('submit(saveBtn)', function (res) {
            var requestData = res.field;
            var pk = requestData.id
            // 提交 Ajax 成功后，关闭当前弹层并重载表格
            $.ajax({
                url: 'http://127.0.0.1:8000/user/user/' + pk + '/',
                type: 'PUT',
                headers: {
                        'Authorization': localStorage.getItem('token')
                    },
                ContentType: 'application/json',
                data: {
                    'id': requestData.id,
                    'username': requestData.username,
                    'gender': requestData.gender === '男' ? "M" : "F",
                    'phone': requestData.phone,
                    'email': requestData.email,
                    'occupation': requestData.occupation,
                    'Remarks': requestData.Remarks,
                },
                success: function (data) {
                    var iframeIndex = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(iframeIndex);
                    parent.layui.table.reload('currentTableId'); // 刷新表格
                    parent.layer.msg(data.message, {icon: 6});
                }
            });

        });
        return false;
    });